package com.openbravo.data.loader;

import com.openbravo.data.basic.BasicException;

public class SerializerReadDatas implements SerializerRead {
    
    private Datas[] m_classes;
    
    /** Creates a new instance of SerializerReadBasic */
    public SerializerReadDatas(Datas... classes) {
        m_classes = classes;
    }
    
    public Object readValues(DataRead dr) throws BasicException {
    	if(m_classes.length==1)
    		return m_classes[0].getValue(dr, 1);
        Object[] m_values = new Object[m_classes.length];
        for (int i = 0; i < m_classes.length; i++) {
            m_values[i] = m_classes[i].getValue(dr, i + 1);
        }
        return m_values;
    }
    
      public Object readValues(DataRead dr,int[] indexs) throws BasicException {

        Object[] m_values = new Object[indexs.length];
        for (int i = 0; i < indexs.length; i++) {
            m_values[i] = m_classes[indexs[i]].getValue(dr, i + 1);
        }
        return m_values;
    }
}
